# coding: utf-8
# Author: Legend奇
# @Time： 2020/8/26 上午10:28
from tortoise.contrib.pydantic import pydantic_model_creator, pydantic_queryset_creator
from tortoise.contrib.pydantic.base import _get_fetch_fields

from apps.iacs.models import *

UserSchema = pydantic_model_creator(User, name="UserSchema", exclude=('password', 'is_active', 'creator'))
MenuSchema = pydantic_model_creator(Menu, name="MenuSchema")
MenuListSchema = pydantic_queryset_creator(Menu, name="MenuListSchema")
ApiSchema = pydantic_model_creator(Api, name="ApiSchema")
ApiListSchema = pydantic_queryset_creator(Api, name="ApiListSchema")
PermissionGroupSchema = pydantic_model_creator(PermissionGroup, name="PermissionGroupSchema")

if __name__ == '__main__':
    print(dir(MenuSchema))
    print(dir(MenuSchema.__config__))
    print(getattr(MenuSchema.__config__, "orig_model"))
    print(_get_fetch_fields(MenuSchema, getattr(MenuSchema.__config__, "orig_model")))
# class MenuSerializer(MenuSchema):
#     sub_menu = get_sub_menu
#
#     def get_sub_menu(self):
